package controller

import (
	"github.com/gin-gonic/gin"
	"goskeleton/app/model"
	"goskeleton/app/utils/response"
)

type UserController struct {
}

func (pc *UserController) UpdateAvatarUrl(context *gin.Context) {
	//根据OpenID去修改用户的头像，传递过来的参数json是openId,和url
	var userInfo model.UserModel
	err := context.ShouldBindJSON(&userInfo)
	if err != nil {
		response.Fail(context, 400, "参数错误", nil)
		return
	}
	user := model.CreateUserFactory1(`mysql`)
	user.UpdateAvatarUrl(userInfo.OpenId, userInfo.AvatarUrl)
	response.Success(context, "修改成功", nil)
}
